<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input id="addBtn" type="button" value="增加数据">
    <script src="../js/mock-min.js"></script>
    <script src="./data.js"></script>
    <script src="./ajax.js"></script>
    <script>
        let addBtn = document.getElementById("addBtn");
        addBtn.onclick = function(){
            // let xhr = new XMLHttpRequest();
            // xhr.onreadystatechange = function(){
            //     if(xhr.readyState == 4 && xhr.status == 200){
            //         let text = JSON.parse(xhr.responseText);
            //         console.log("服务器响应数据：" , typeof text,text.msg);
            //     }
            // }
            // xhr.open("post","/addData");
            // xhr.send({
            //     name:"zhangsan",age:20
            // });
            ajax({
                type:"post",
                url:"/addData",
                data:{
                    name:"zhangsan",age:20
                },
                success:function(res){
                    console.log(res);
                }
            });
        }

        
    </script>
</body>
</html>